package com.baili.dao.user;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.baili.dao.base.BaseDao;
import com.baili.dto.ProductOrder;
import com.baili.dto.SelectUserInput;
@Repository("userDao")
public class UserDaoImpl extends BaseDao implements UserDao {

	@Override
	public Map<String, Object> getUserByMobile(SelectUserInput selectUserInput){
		
		List<Map<String, Object>> userlist = this.sqlSessionTemplate.selectList("login.getUserByMobile", selectUserInput);
		
		if(userlist != null && userlist.size()>0){
			
			Map<String, Object> map = userlist.get(0);
			
			return map;
			
		}
		return null;
	}

	@Override
	public void saveEntity(Object o) {
		this.sqlSessionTemplate.insert("login.insert", o);
	}
	
	@Override
	public void insertOrg(Object o) {
		this.sqlSessionTemplate.insert("login.insertOrg", o);
	}

	@Override
	public List selectOrganization(){
		return this.sqlSessionTemplate.selectList("login.selectOrganization");
	}
	
	@Override
	public List selectUserRole(SelectUserInput selectUserInput){
		return this.sqlSessionTemplate.selectList("login.selectUserRole",selectUserInput);
	}

	@Override
	public Map<String, Object> getUserByMobileOM(SelectUserInput selectUserInput) {
		
		List<Map<String, Object>> userlist = this.sqlSessionTemplate.selectList("login.getUserByMobileOM", selectUserInput);
		
		if(userlist != null && userlist.size()>0){
			
			Map<String, Object> map = userlist.get(0);
			
			return map;
			
		}
		return null;
	}

	@Override
	public Map<String, Object> getUserByMobileTPF(SelectUserInput selectUserInput) {
		
		List<Map<String, Object>> userlist = this.sqlSessionTemplate.selectList("login.getUserByMobileTPF", selectUserInput);
		
		if(userlist != null && userlist.size()>0){
			
			Map<String, Object> map = userlist.get(0);
			
			return map;
			
		}
		return null;
	}

	@Override
	public List getRole() {
		return this.sqlSessionTemplate.selectList("login.getRole");
	}

	@Override
	public void updateUser(SelectUserInput selectUserInput) {
		// TODO Auto-generated method stub
		this.sqlSessionTemplate.update("login.getRole", selectUserInput);
	}

	@Override
	public List getUserByMobileAndName(SelectUserInput selectUserInput) {
		
		return this.sqlSessionTemplate.selectList("login.getUserByMobileAndName", selectUserInput);
	}
	@Override
	public List getRoleTypeByUserId(SelectUserInput selectUserInput) {
		
		return this.sqlSessionTemplate.selectList("login.getRoleTypeByUserId", selectUserInput);
	}
	@Override
	public List getUserByRoleType(SelectUserInput selectUserInput) {
		
		return this.sqlSessionTemplate.selectList("login.getUserByRoleType", selectUserInput);
	}
	@Override
	public List getUserForProcessName(int id) {
		
		Map map = new HashMap();
		
		map.put("id", id);
		
		return this.sqlSessionTemplate.selectList("login.getUserForProcessName", map);
	}
	@Override
	public List getUserForProcessNameForTeam(int id) {
		
		Map map = new HashMap();
		
		map.put("id", id);
		
		return this.sqlSessionTemplate.selectList("login.getUserForProcessNameForTeam", map);
	}
	@Override
	public List getUserByProcessId(ProductOrder productOrder) {
		
		return this.sqlSessionTemplate.selectList("login.getUserByProcessId", productOrder);
	}

	
}
